/**
 *  ItemFactory.java : IceBird project
 *  14:54:37 
 */
package icebird.compiler.x86.old;

import icebird.metadata.BasicType;

/**
 * @author Sergey Shulepoff[Knott]
 */
public final class ItemFactory {
	// TODO: Implement item factory.
	
	public WordItem createReg(EmitterContext c, BasicType type, X86Register r) {
		WordItem i = createWord(type);
		i.init(c, Item.GPR, r, (short)0);
		return i;
	}
	
	public IntegerItem createIConst(EmitterContext c, int v) {
		IntegerItem i = new IntegerItem(this);
		i.init(c, Item.CONSTANT, (short)0, null, v);
		return i;
	}
	
	public FloatItem createFConst(EmitterContext c, float v) {
		FloatItem f = new FloatItem(this);
		f.init(c, Item.CONSTANT, (short)0, null, v);
		
		return f;
	}
	
	private WordItem createWord(BasicType t) {
		switch (t.getCharacter()) {
		case 'I':
			return new IntegerItem(this);
			
		case 'F':
			return new FloatItem(this);
			
		// TODO: Implement this.
			
		default:
			throw new IllegalArgumentException();
		}
	}
}
 